##
## configure.ac for PySL
##


#
# Package info and autoconf initialization
#

AC_PREREQ(2.59)
AC_INIT([PySL], [0.9.0],
	[Chris Stawarz  <chris@pseudogreen.org>],
	[pysl])
AC_CONFIG_SRCDIR([libpysl/libpysl.c])
AC_CONFIG_AUX_DIR(config)

# Preprocessor macro for version number
AC_DEFINE_UNQUOTED(PACKAGE_VERSION_NUMBER, 0*10000+9*100+0)

AM_INIT_AUTOMAKE(pysl, $PACKAGE_VERSION)
AC_PROG_CC
AC_DISABLE_STATIC
AC_PROG_LIBTOOL


#
# Python configuration
#

AZ_PYTHON_PATH()
AZ_PYTHON_VERSION_ENSURE([2.3])
AZ_PYTHON_CSPEC
AZ_PYTHON_LSPEC

AC_MSG_CHECKING([for numpy headers])
AZ_PYTHON_RUN([[import numpy ; print numpy.get_include()]])
if test $az_python_cc -ne 0
then
  AC_MSG_ERROR([cannot find numpy header files])
fi
AC_MSG_RESULT([$az_python_output])
AC_SUBST([NUMPY_INC], [$az_python_output])


#
# S-Lang configuration
#

AC_ARG_WITH(slang,
	[AC_HELP_STRING([--with-slang=DIR], [Use DIR/include and DIR/lib for slang [/usr/local]])],
	[SLANG=$withval],
	[SLANG=/usr/local])

AC_ARG_WITH(slanginc,
	[AC_HELP_STRING([--with-slanginc=DIR], [slang include files in DIR])],
	[SLANG_INC=$withval],
	[SLANG_INC=$SLANG/include])

AC_ARG_WITH(slanglib,
	[AC_HELP_STRING([--with-slanglib=DIR], [slang library in DIR])],
	[SLANG_LIB=$withval],
	[SLANG_LIB=$SLANG/lib])

AC_SUBST(SLANG_INC)
AC_SUBST(SLANG_LIB)

AC_MSG_CHECKING([S-Lang version])
slang_ver=`grep SLANG_VERSION $SLANG_INC/slang.h | head -1 | awk '{print $3}'`
if test $? -ne 0 -o x$slang_ver = x
then
  AC_MSG_ERROR([cannot determine S-Lang version])
fi
AC_MSG_RESULT([$slang_ver])
if test $slang_ver -lt 20000
then
  AC_MSG_ERROR([S-Lang version 2.0.0 or later is required])
fi


#
# autoconf output
#

AC_CONFIG_FILES([
	   Makefile
	   libpysl/Makefile
	   pymodule/Makefile
	   pymodule/setup.py
	   slmodule/Makefile
	  ])
AC_OUTPUT
